import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from '@nestjs/common';
import { CodeSnippetService } from './code-snippet.service';
import { CreateCodeSnippetDto } from './dto/create-code-snippet.dto';
import { UpdateCodeSnippetDto } from './dto/update-code-snippet.dto';

@Controller('code-snippet')
export class CodeSnippetController {
    constructor(private readonly codeSnippetService: CodeSnippetService) { }

    @Post()
    create(@Body() createCodeSnippetDto: CreateCodeSnippetDto) {
        return this.codeSnippetService.create(createCodeSnippetDto);
    }
    @Post('/query')
    create1(@Body() body: { keyword: string, pageNo: number, pageSize: number }) {
        return this.codeSnippetService.findAll(body);
    }

    @Get()
    findAll(@Query() query: { keyword: string, pageNo: number, pageSize: number }) {
        return this.codeSnippetService.findAll(query);
    }

    @Get(':id')
    findOne(@Param('id') id: string) {
        return this.codeSnippetService.findOne(+id);
    }

    @Patch(':id')
    update(@Param('id') id: string, @Body() updateCodeSnippetDto: UpdateCodeSnippetDto) {
        return this.codeSnippetService.update(+id, updateCodeSnippetDto);
    }

    @Delete(':id')
    remove(@Param('id') id: string) {
        return this.codeSnippetService.remove(+id);
    }
}
